package com.gs.SynPatrolRep.control;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;

import androidx.appcompat.widget.AppCompatEditText;

public class EditTextDC extends AppCompatEditText {
    public EditTextDC(Context context) {
        super(context);
    }

    public EditTextDC(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public EditTextDC(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        Drawable[] drawables = getCompoundDrawables();
        Drawable drawable = drawables[0];
        if (drawable != null) {
            int drawableWidth = drawable.getIntrinsicWidth();
            int drawablePadding = getCompoundDrawablePadding();
            float textWidth = getPaint().measureText(getText().toString());
            float bodyWidth = drawableWidth + drawablePadding + textWidth;
            canvas.save();
            canvas.translate((getWidth() - bodyWidth - 100) / 2, 0);
        }
        super.onDraw(canvas);

    }
}
